Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit a74e0f9cf7e634fc30cada690c6b79d8bb5d6c93


Parents : 93d214e
Author : Mark Qvist <mark@unsigned.io>
Date : 2022-10-02T12:15:37+02:00

Notification logic

Changes

3 files changed, 13 insertions(+), 3 deletions(-)


Diff

diff --git a/sbapp/main.py b/sbapp/main.py
index 75818900..9e2c9f53 100644
--- a/sbapp/main.py
+++ b/sbapp/main.py
@@ -160,6 +160,7 @@ class SidebandApp(MDApp):
def on_resume(self):
self.sideband.setstate("app.running", True)
self.sideband.setstate("app.foreground", True)
+ self.sideband.setstate("wants.clear_notifications", True)
self.app_state = SidebandApp.ACTIVE
def on_stop(self):
@@ -494,6 +495,7 @@ class SidebandApp(MDApp):
self.root.ids.screen_manager.current = "conversations_screen"
self.root.ids.messages_scrollview.active_conversation = None
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
+ self.sideband.setstate("wants.clear_notifications", True)
def connectivity_status(self, sender):
hs = dp(22)

diff --git a/sbapp/services/sidebandservice.py b/sbapp/services/sidebandservice.py
index 030b5da3..6638365a 100644
--- a/sbapp/services/sidebandservice.py
+++ b/sbapp/services/sidebandservice.py
@@ -157,6 +157,11 @@ class SidebandService():
self.should_run = False
sleep_time = 0
+ if self.sideband.getstate("wants.clear_notifications"):
+ self.sideband.setstate("wants.clear_notifications", False)
+ if self.notification_service != None:
+ self.notification_service.cancelAll()
+
time.sleep(sleep_time)
self.release_locks()

diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py
index a2c68b8f..16338bad 100644
--- a/sbapp/sideband/core.py
+++ b/sbapp/sideband/core.py
@@ -1096,9 +1096,6 @@ class SidebandCore():
context_dest = message.source_hash
is_trusted = self.is_trusted(context_dest)
- if is_trusted:
- should_notify = True
-
if self._db_message(message.hash):
RNS.log("Message exists, setting state to: "+str(message.state), RNS.LOG_DEBUG)
self._db_message_set_state(message.hash, message.state)
@@ -1106,6 +1103,9 @@ class SidebandCore():
RNS.log("Message does not exist, saving", RNS.LOG_DEBUG)
self._db_save_lxm(message, context_dest)
+ if is_trusted:
+ should_notify = True
+
if self._db_conversation(context_dest) == None:
self._db_create_conversation(context_dest)
self.setstate("app.flags.new_conversations", True)
@@ -1121,6 +1121,9 @@ class SidebandCore():
self.unread_conversation(context_dest)
self.setstate("app.flags.unread_conversations", True)
+ if self.gui_display() == "conversations_screen" and self.gui_foreground():
+ should_notify = False
+
if self.is_client:
should_notify = False


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────